﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using PHMEE.Admin.Application.Contracts.IServices.DaqInfo.WaveIntervals;
using PHMEE.Admin.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE.Admin.HttpApi.Controllers.MqttInfo
{
    [Route("phmeeadmin/api/[controller]/[action]")]
    public class CollectParaController : PHMEEAdminController
    {
        private ICollectParaAppService _iCollectParaAppService;
        public CollectParaController(ICollectParaAppService iCollectParaAppService)
        {
            _iCollectParaAppService = iCollectParaAppService;
        }
        /// <summary>
        /// 创建CollectPara数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<IActionResult> CreateCollectPara([FromBody] List<VibChannelParaCreateDto> VibChannelList)
        {
            await _iCollectParaAppService.CreateCollectParameterAsync(VibChannelList);
            return Ok(new { Message = "Success" });

        }
        /// <summary>
        ///Form表单查看采集参数集合
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<List<VibChannelParaFormDto>> GetBySysCollectPara(Guid sysParaId)
        {
            return await _iCollectParaAppService.GetBySysCollectParaAsync(sysParaId);
        }
        /// <summary>
        /// Form更新采集参数集合
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [AllowAnonymous]
        public async Task<IActionResult> UpdateCollectorPara([FromBody] List<VibChannelParaUpdateDto> VibChannelListDto, Guid sysParaId)
        {
            await _iCollectParaAppService.UpdateCollectorAsync(VibChannelListDto, sysParaId: sysParaId);
            return Ok(new { Message = "Success" });
        }
        /// <summary>
        /// 根据采集站信息获取CollectPara数据--Mqtt下发参数使用
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public async Task<List<VibChannelParaDto>> GetBySysMqttPara(string collectorCode)
        {
            return await _iCollectParaAppService.GetByVibChannelListMqttAsync(collectorCode);
        }
    }
}
